﻿@using NuGet.Server.DataServices;
@using MayhemServer.Extensions;
@using MayhemServer.Models;
@using Microsoft.Web.Helpers;
@model PageSet<Package>
@{
	var previousIndex = Model.PageIndex > 0 ? (Model.PageIndex - 1) : 0;
	var nextIndex = (((Model.PageIndex * Model.PageSize) + Model.Items.Count()) < Model.TotalItemCount) ? (Model.PageIndex + 1) : Model.PageIndex;
}
<div id="body-top">
	<h1>
		Avaliable Add-ons</h1>
</div>
<div id="module-list">
	<!--<div class="pager">
        <a href="@Url.RouteUrl("Packages", new { pageIndex = previousIndex })"><< Prev</a> | <a href="@Url.RouteUrl("Packages", new { pageIndex = nextIndex })">Next >></a>
    </div>-->
	@foreach (var item in Model.Items)
 {
	 var url = Url.RouteUrl("Package", new { id = item.Id }, Request.Url.Scheme);
		<div class="module">
			<h4 class="module-name">
				<a href="@url">@item.GetTitle()</a>
			</h4>
			<div class="module-metadata">
				<p>
					<span class="module-info-header">Developer</span> <span class="module-info-text">@item.Authors</span>
					<br />
					<span class="module-info-header">Updated</span> <span class="module-info-text">@item.LastUpdated.ToShortDateString()</span>
					<br />
					<span class="module-info-header">Description</span> <span class="module-info-text">@item.GetShortDescription()</span>
				</p>
			</div>
			<div class="module-stats">
				<p>
					<span class="module-info-header">Version</span> <span class="module-info-text">@item.Version</span>
					<br />
					<span class="module-info-header">Downloads</span> <span class="module-info-text">@item.DownloadCount</span>
				</p>
			</div>
			<div class="module-links">
				<a class="button" href="@Url.RouteUrl("Download", new { id = item.Id })">Download</a>
				@Facebook.LikeButton(url, buttonLayout: "button_count", action: "recommend", width: 180, height: 25)
			</div>
		</div>
	 
 }
</div>
